package com.hospital.hospitalserver.controller;

import com.hospital.hospitalserver.entity.DepartmentInfo;
import com.hospital.hospitalserver.mapper.DepartmentTypeMapper;
import com.hospital.hospitalserver.service.DepartmentService;
import com.hospital.hospitalserver.service.DepartmentTypeService;
import com.hospital.hospitalserver.util.Pager;
import com.hospital.hospitalserver.util.Response;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * 科室相关方法API请求接口
 * */
@CrossOrigin
@RestController
@RequestMapping("/department")
@RequiredArgsConstructor
public class DepartmentController {
    private final DepartmentService departmentService;
    private final DepartmentTypeService departmentTypeService;

    /**
     * 添加科室
     * */
    @PostMapping("/addDepartment")
    public Response addDepartment(@RequestBody DepartmentInfo departmentInfo){
        return departmentService.addDepartment(departmentInfo);
    }

    /**
     * 编辑科室
     * */
    @PostMapping("/editDepartment")
    public Response editDepartment(@RequestBody DepartmentInfo departmentInfo){
        return departmentService.editDepartment(departmentInfo);
    }

    /**
     * 科室管理-根据搜索条件查询科室分页数据
     * */
    @PostMapping("/getDepartmentPager")
    public Response getDepartmentPager(@RequestBody Pager pager){
        return departmentService.getDepartmentPagerDataBySearch(pager);
    }

    /**
     * 查询科室列表数据
     * 提供给医生、护士等管理页面选择
     * */
    @GetMapping("/getDepartmentList")
    public Response getDepartmentList(){
        return departmentService.getDepartmentList();
    }

    /**
     * 加载科室类型列表数据
     * */
    @GetMapping("/getDepartmentTypeList")
    public Response getDepartmentTypeList(){
        return departmentTypeService.getDepartmentTypeList();
    }
}
